<?php
$loc ="register";
require_once('mysql_connect.php');

if ($accountreg==1){
}else{
	header("Location:login.php");
	exit();
}

if(isset($_POST['submit'])){
	$password = escape_data($_POST['password']);
	$passwordtwo = escape_data($_POST['passwordtwo']);
	if($passwordtwo == $password){
		$p = TRUE;
	}else{
		$p = FALSE;
		$passwordf = "<LI>Your passwords do not match";
	}
	$login = strtolower(escape_data($_POST['email']));
	$phone = str_replace("-", "", str_replace(")", "", str_replace("(","", str_replace(" ","", $_POST['phone']))));
	if(is_numeric($phone)){
		$f = TRUE;
	}else{
		$f = FALSE;
		$phonef = "<LI>Your phone number is not a number";
	}
			
	$query = "SELECT * FROM users WHERE email='" . $login . "'";
	$result = mysql_query($query);
	if(mysql_num_rows($result) == 0 && $f && $p){
		$insertquery = "INSERT INTO users(email, phone, password, admin) VALUES('{$login}', {$phone}, PASSWORD('{$password}'), 0)";
		$inserresult = mysql_query($insertquery);
		header("Location:login.php");
		exit();
	}else{
		$mes = "I'm sorry but somthing is wrong with your data<UL>";
	}
}
include('top.php');
?>
<TABLE><TR><TD>
<?php
if(isset($mes)){
echo "<FONT FACE=\"Verdana\" size=-1 color=\"red\">";
echo $mes;
echo $phonef;
echo $passwordf;
echo "</UL></FONT><BR>";
}
?>
<FORM ACTION="register.php" method="post"><FONT FACE="Verdana" size=-1>email: </FONT><INPUT TYPE="text" name="email" id="email">
<BR><FONT FACE="Verdana" size=-1>phone: </FONT><INPUT TYPE="text" name="phone" id="phone">
<BR><FONT FACE="Verdana" size=-1>password: <INPUT TYPE="password" name="passwordtwo" id="passwordtwo">
<BR><FONT FACE="Verdana" size=-1>again: <INPUT TYPE="password" name="password" id="password"><BR><INPUT TYPE="submit" name="submit" id="submit" value="register"></FONT></FORM>
<BR><A HREF="login.php"><FONT FACE="Verdana" color="000000" size=-1>login</FONT></A><FONT FACE="Verdana" color="000000" size=-1> | </FONT><A HREF="lostpass.php"><FONT FACE="Verdana" color="000000" size=-1>lost password</FONT></A>
</TD></TR></TABLE>
<?php
include('bot.php');
?>